package algdat;

/**
 * @author Mikko Puustinen (mikko.puustinen@gmail.com)
 * @version 0.1, 2007-nov-15
 */
public class Ovning16 {
    static int iter = 0;

    private int euklides(int a, int b) {
        iter++;
        //System.out.println("a: " + a + ", b: " + b);
        if (b == 0 || a % 2 == 0 && b % 2 == 0) {
            //System.out.println("Klar");
            return a;
        } else {
            return euklides(b, a % b);
        }

    }

    private Ovning16() {
        int antal = 0;
        int max = 30;
        System.out.println("Antalet relativt primitiva tal till " + max);
        for (int i = 1; i <= max; i++) {
            if (euklides(max, i) == 1)
                antal++;
        }
        System.out.println(iter + "\n" + antal);
    }

    public static void main(String[] args) {
        new Ovning16();
    }
}
